package com.jumi.microservice.stock;

import com.jumi.microservice.domain.GoodsStockDO;
import com.jumi.microservice.domain.GoodsStockLogDO;
import com.jumi.microservice.domain.GoodsWarehouseStockDO;
import com.jumi.microservice.domain.OrderItemDTO;
import com.jumi.microservice.mapper.GoodsStockLogMapper;
import com.jumi.microservice.mapper.GoodsStockMapper;
import com.jumi.microservice.mapper.GoodsWarehouseStockMapper;
import com.jumi.microservice.stock.factory.AbstractStockOrderUpdaterFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;


/**
 * - - - - - - - - - - - - - - -
 * 取消订单工厂组件
 * @author liuz
 * @date 2020/9/8 17:26
 * ToDoSomeThing
 * - - - - - - - - - - - - - - -
 */
@Component
public class CancelOrderUpdaterFactory<T>
		extends AbstractStockOrderUpdaterFactory<T> {

	/**
	 * 构造函数
	 * @param goodsStockMapper
	 */
	@Autowired
	public CancelOrderUpdaterFactory(
			GoodsStockMapper goodsStockMapper, GoodsStockLogMapper goodsStockLogMapper, GoodsWarehouseStockMapper goodsWarehouseStockMapper) {
		super(goodsStockMapper,goodsStockLogMapper,goodsWarehouseStockMapper);
	}

	/**
	 * 创建库存更新命令
	 *
	 * @param parameter   参数
	 * @param goodsStockDO 商品库存对象
	 * @param goodsStockLogDO 库存流水对象
	 * @param goodsWarehouseStockDOS 商品仓库库存DO对象集合
	 * @return 库存更新命令
	 * @throws Exception
	 */
	@Override
	protected StockUpdater create(GoodsStockDO goodsStockDO,
								  GoodsStockLogDO goodsStockLogDO,
								  GoodsWarehouseStockDO goodsWarehouseStockDOS,
								  T parameter) throws Exception {
		OrderItemDTO orderItemDTO = (OrderItemDTO) parameter;
		return new CancelOrderUpdater(goodsStockDO, goodsStockLogDO,
				goodsWarehouseStockDOS, goodsStockMapper, goodsWarehouseStockMapper, goodsStockLogMapper, orderItemDTO);
	} 

}
